<template>
  <div class="Layout full">
    <div class="header">
      <ul class="nav">
        <li><span style="font-family:Comic Sans MS;font-size:14px;">
            <div class="menu-icon" @click="clickMenu"></div>
          </span>
        </li>
      </ul>
    </div>
    <div class="dasmaI" :class="isActive?'':'no_active'">
      <div class="scl" :class="isActive?'':'no_active'">
        <ul class="nav">
          <li v-for="item in menuList" :key="item.key">
            <router-link :to="{path: item.path }">
              <span>{{item.name}}</span>
            </router-link>
          </li>
        </ul>
      </div>
      <div class="bfmk" @click="isActive = false" :class="isActive?'':'no_active'"></div>
    </div>
    <div class="container">
      <router-view v-show="$route.name" />
      <section v-show="!$route.name" id="frame"></section>
    </div>
  </div>
</template>
<script>
export default {
  name: 'Layout',
  data() {
    return {
      menuList: [
        {
          name: 'Home',
          key: '1',
          path: '/Childs'
        },

        {
          key: '2',
          name: 'Vue-1',
          path: '/vue'
        },
        {
          key: '3',
          name: 'Vue-2',
          path: '/vue/about'
        }
      ],
      isActive: false
    }
  },
  created() {
    console.log(this.$route.name)
  },
  methods: {
    go(path) {
      this.$router.push({ path: path })
    },
    clickMenu() {
      this.isActive = !this.isActive
    }
  }
}
</script>
<style lang="less" scoped>
.menu-icon {
  display: inline-block;
  width: 30px;
  height: 3px;
  padding: 5px 0;
  border-top: 3px solid;
  border-bottom: 3px solid;
  background-color: currentColor;
  background-clip: content-box;
}
.dasmaI {
  display: flex;
  position: fixed;
  top: 53px;
  right: 0px;
  bottom: 0px;
  left: 0px;
  z-index: 998;
  &.no_active {
    width: 0px;
    overflow: hidden;
  }
  .scl {
    position: relative;
    z-index: 10;
    box-shadow: rgba(0, 0, 0, 0.2) 0px 1px 4px 0px;
    background-color: rgb(255, 255, 255);
    width: 240px;
    height: 100%;
    transition: all 0.25s ease-in-out 0s;
    &.no_active {
      transform: translateX(-100%);
    }
  }
  .bfmk {
    position: absolute;
    z-index: 1;
    background-color: rgba(0, 0, 0, 0.2);
    width: 100vw;
    height: 100vh;
    transition: opacity 0.25s ease-in-out 0s;
    visibility: visible;
    opacity: 1;
    &.no_active {
      visibility: hidden;
      opacity: 0;
    }
  }
}
.header {
  background: #4d4d4d;
  .nav {
    color: #fff;
    padding: 15px;
    display: flex;
    a {
      text-decoration: none;
      color: #fff;
    }
    li {
      margin: 0 10px;
      list-style: none;
      cursor: pointer;
    }
  }
}
.container {
  height: 100%;
  width: 100%;
  position: relative;
}
</style>
